package guowei.guliuser.user.web;

import com.alibaba.fastjson.JSON;
import guowei.common.utils.R;
import guowei.common.vo.MemberVo;
import guowei.guliuser.user.feign.OrderFeign;
import guowei.guliuser.user.intercaptor.MemberInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class OrderListWeb {

    @Autowired
    OrderFeign orderFeign;

    @GetMapping("/orderlist.html")
    public String getListInfo(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model){
        
//   todo 查询当前登录用户的所有订单信息       因此要加入拦截器
        Map<String,Object> params = new HashMap<>();
        params.put("page",pageNum.toString());
        R r = orderFeign.getOrdersByMemberId(params);
        model.addAttribute("orders",r);
        System.out.println(JSON.toJSONString(r));
        return "orderlist";
    }
}
